package org.sixtynine.stock.service.impl;

import java.util.Date;
import java.util.List;

import org.sixtynine.stock.dao.MonthlySectorDataDao;
import org.sixtynine.stock.dto.GridPramDTO;
import org.sixtynine.stock.dto.Page;
import org.sixtynine.stock.entity.MonthlySectorData;
import org.sixtynine.stock.service.MonthlySectorDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Thilan
 * 
 */

@Service
public class MonthlySectorDataServiceImpl implements MonthlySectorDataService {

	@Autowired
	private MonthlySectorDataDao monthlySectorDataDao;

	@Override
	public MonthlySectorData findById(int id) {
		return monthlySectorDataDao.findById(id);
	}

	@Override
	@Transactional(readOnly = false)
	public void saveMonthlySectorData(MonthlySectorData monthlySectorData) {
		monthlySectorDataDao.saveMonthlySectorData(monthlySectorData);
	}

	@Override
	@Transactional(readOnly = false)
	public void deleteMonthlySectorData(int id) {
		MonthlySectorData monthlySectorData = monthlySectorDataDao.findById(id);
		if (monthlySectorData != null) {
			monthlySectorDataDao.delete(monthlySectorData);
		}
	}

	@Override
	public List<MonthlySectorData> findMonthlySectorData(int id) {
		return monthlySectorDataDao.findMonthlySectorData(id);
	}

	@Override
	public List<MonthlySectorData> searchMonthlySectorData(int sectorId,
			Date fromDate, Date toDate, String orderBy, String orderByName) {
		return monthlySectorDataDao.searchMonthlySectorData(sectorId, fromDate,
				toDate, orderBy, orderByName);
	}

	@Override
	public Page<MonthlySectorData> searchMonthlySectorData(int sectorId,
			Date fromDate, Date toDate, String orderBy, String orderByName,
			GridPramDTO gridPramDTO) {
		return monthlySectorDataDao.searchMonthlySectorData(sectorId, fromDate,
				toDate, orderBy, orderByName, gridPramDTO);
	}

	@Override
	public void deleteMonthlySectorData(int sectorId, Date fromDate, Date toDate) {
		monthlySectorDataDao
				.deleteMonthlySectorData(sectorId, fromDate, toDate);
	}

}
